/*-------------------------------------------------------------------------
 * CLR版本:     4.0.30319.42000
 * 创建人:      song
 * 创建时间：   2024/4/9 15:39:39
 * 功 能：      设备信息
 *-------------------------------------------------------------------------*/

using UnityEngine;

namespace SCore.Util
{
    public class DeviceUtils
    {
        public static int GetAutoQualitySetting()
        {
            // 目前一一匹配了
            return GetDeviceLevel();
        }

        private static int GetDeviceLevel()
        {
            var gravendor = SystemInfo.graphicsDeviceVendor;
            var graname = SystemInfo.graphicsDeviceName;
            var sysmemory = SystemInfo.systemMemorySize;

            if (gravendor.Contains("Qualcomm"))
            {
                if (graname.Contains("740") || graname.Contains("730") || graname.Contains("642") ||
                    graname.Contains("725") || graname.Contains("690")
                    || graname.Contains("685") || graname.Contains("680") || graname.Contains("660") ||
                    graname.Contains("644") || graname.Contains("643")
                    || graname.Contains("650") || graname.Contains("640")
                   )
                {
                    return 2;
                }
                else if (graname.Contains("620") || graname.Contains("619") || graname.Contains("618")
                         || graname.Contains("610") || graname.Contains("612") || graname.Contains("616")
                         || graname.Contains("615") || graname.Contains("530") || graname.Contains("540") ||
                         graname.Contains("630"))
                {
                    return 1;
                }
                else if (graname.Contains("512") || graname.Contains("510") || graname.Contains("509") ||
                         graname.Contains("508"))
                {
                    return 0;
                }
                else if (graname.Contains("506") || graname.Contains("505") || graname.Contains("504") ||
                         graname.Contains("430") || graname.Contains("420")
                         || graname.Contains("418") || graname.Contains("405") || graname.Contains("330") ||
                         graname.Contains("320") || graname.Contains("308")
                         || graname.Contains("306") || graname.Contains("305") || graname.Contains("304") ||
                         graname.Contains("225"))
                {
                    return 0;
                }
            }
            else if (gravendor.Contains("Apple"))
            {
                if (graname.Contains("M1") || graname.Contains("M2"))
                {
                    return 2;
                }

                if (graname.Contains("A12") || graname.Contains("A13") || graname.Contains("A14") ||
                    graname.Contains("A15") || graname.Contains("A16"))
                {
                    return 2;
                }
                else if (graname.Contains("A11") || graname.Contains("A10X") || graname.Contains("A9X"))
                {
                    return 2;
                }
                else
                    return 1;
            }
            else if (gravendor.Contains("ARM"))
            {
                if (graname.Contains("G715") || graname.Contains("G710") || graname.Contains("G610") ||
                    graname.Contains("G78")
                    || graname.Contains("G77") || graname.Contains("G76"))
                {
                    return 2;
                }
                else if (graname.Contains("G510") || graname.Contains("G57") || graname.Contains("G68"))
                {
                    return 1;
                }
                else if (graname.Contains("G72") || graname.Contains("G71") || graname.Contains("G52") ||
                         graname.Contains("G51")
                         || graname.Contains("T880") || graname.Contains("T860"))
                {
                    return 0;
                }
                else if (graname.Contains("T830") || graname.Contains("T820") || graname.Contains("T764")
                         || graname.Contains("T760") || graname.Contains("T720") || graname.Contains("T628")
                         || graname.Contains("T624") || graname.Contains("T604") || graname.Contains("G31")
                         || graname.Contains("400") || graname.Contains("450"))
                {
                    return 0;
                }
            }
            else if (gravendor.Contains("Imagination"))
            {
                if (graname.Contains("GM9446"))
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }
            else if (graname.Contains("virgl") || graname.Contains("MuMu") || graname.Contains("ANGLE") ||
                     graname.Contains("Android Emulator"))
            {
                return 2;
            }

            if (sysmemory > 8000)
                return 2;
            else if (sysmemory > 4000)
                return 1;
            else
                return 0;
        }
    }
}